<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      function add() {
        var inputNum1 = document.getElementById('num1').value
        var inputNum2 = document.getElementById('num2').value
        console.log('num1:' + inputNum1 + ',num2:' + inputNum2)
        document.getElementById('rs').value = parseInt(inputNum1)+parseInt(inputNum2)
      }

      function minus() {
        var inputNum1 = document.getElementById('num1').value
        var inputNum2 = document.getElementById('num2').value
        console.log('num1:' + inputNum1 + ',num2:' + inputNum2)
        document.getElementById('rs').value = inputNum1-inputNum2
      }

      function muti() {
        var inputNum1 = document.getElementById('num1').value
        var inputNum2 = document.getElementById('num2').value
        console.log('num1:' + inputNum1 + ',num2:' + inputNum2)
        document.getElementById('rs').value = inputNum1*inputNum2
      }

      function div() {
        var inputNum1 = document.getElementById('num1').value
        var inputNum2 = document.getElementById('num2').value
        console.log('num1:' + inputNum1 + ',num2:' + inputNum2)
        document.getElementById('rs').value = inputNum1/inputNum2
      }
    </script>
  </head>
  <body>
    <h1>计算器1</h1>
    <!-- 拷贝当前行 shift+alt+下 -->
    <input type="number" id="num1" placeholder="请输入第一个数" /> <br />
    <input type="number" id="num2" placeholder="请输入第二个数" /> <br />
    <input type="button" value="+" onclick="add()" />
    <input type="button" value="-" onclick="minus()" />
    <input type="button" value="*" onclick="muti()" />
    <input type="button" value="/" onclick="div()" /> <br />
    <input type="number" id="rs" placeholder="计算结果" disabled /> <br />
  </body>
</html>
